package com.hziee.graduate.ticket.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.hziee.graduate.ticket.dao.HistoryDao;
import com.hziee.graduate.ticket.dao.MovieDao;
import com.hziee.graduate.ticket.dto.R;
import com.hziee.graduate.ticket.entity.History;
import com.hziee.graduate.ticket.entity.Movie;
import com.hziee.graduate.ticket.service.HistoryService;
import com.hziee.graduate.ticket.service.MovieService;
import com.hziee.graduate.ticket.utils.DateUtils;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.time.LocalDateTime;


@Service("historyService")
public class HistoryServiceImpl extends ServiceImpl<HistoryDao, History> implements HistoryService {
    @Resource
    private HistoryDao historyDao;
    @Override
    public R<Object> addARecord(Long movieId,Long userId) {
        // 选出电影
        History history = new History();
        history.setMovieId(movieId);
        history.setUserId(userId);
        history.setCreateTime(LocalDateTime.now());
        int insert = historyDao.insert(history);
        if(insert > 0) return R.success("浏览记录存储成功");
        else return R.error("浏览记录存储失败");
    }
}

